put ApplMemory("noDialog:errGlobal") into memAvail
if errGlobal Γëá empty then
answer "Error: ΓÇ£" & errGlobal & "ΓÇ¥"
put empty into errGlobal
else
answer "You have" && memAvail && "bytes available for launching."
end if
end mouseUp
-- part contents for background part 38
----- text -----
3/50
-- part contents for background part 20
----- text -----
An XFCN which returns the size (in bytes) of the largest block of contiguous memory available to any new application. This information is especially helpful when attempting to launch an application, because HyperCard doesn't check the available memory before trying a luanch under MultiFinder. If the launch fails, HC doesn't indicate that anything has happened, so there is no simple way for a script to determine if a launch has been successful. By comparing the amount of memory available with the amount required by the program to be launched (see the XFCN "ApplSize" in this stack) you can predict whether a launch attempt will be successful or not (see note below). The XFCN also works under single Finder and returns the maximum amount of memory that an application could use.
Note: under MultiFinder this XFCN returns results which vary from the number reported by 'About the Finder…' by about 10% (always higher), although the number varies. Comparing the SIZE resource with the amount of free memory reported, the launch fails when there is as little as 60K difference (SIZE = 1000, MFMax = 1060) or as much as 90K difference (SIZE = 4072, MFMax = 4162). In our scripts we warn the user that the launch attempt MAY fail when the amount required is within 10% of the amount available.